package com.first.nell.repay

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Transformations
import com.first.nell.base.BaseViewModel
import com.first.nell.data.ReqBase
import com.first.nell.data.RevObjRepayDetail
import com.first.nell.network.ApiUserReposity

class RepayViewModel : BaseViewModel() {

    /** 当前还款信息 */
    var mFirstNellRepayFirstNellInfo: RevObjRepayDetail? = null

    /** 是否选择展期还款 */
    var isFirstNellRolloverFirstNellRepayment: Boolean = false
    
    /** 获取还款详情 */
    private val mFirstNellFetchFirstNellRepayFirstNellDetailFirstNellLiveData =
        MutableLiveData<ReqBase>()

    /** 判断是否需要还款 */
    private val mFirstNellFetchFirstNellIsFirstNellRepayFirstNellNowFirstNellLiveData =
        MutableLiveData<ReqBase>()

    /** 获取还款链接-加纳 */
    private val mFirstNellFetchFirstNellRepayFirstNellUrlFirstNellGHAFirstNellLiveData =
        MutableLiveData<ReqBase>()

    /** 获取还款链接-乌干达 */
    private val mFirstNellFetchFirstNellRepayFirstNellUrlFirstNellUGXFirstNellLiveData =
        MutableLiveData<ReqBase>()

    /** 获取还款链接-肯尼亚 */
    private val mFirstNellFetchFirstNellRepayFirstNellUrlFirstNellKSHFirstNellLiveData =
        MutableLiveData<ReqBase>()

    /** 获取还款链接-科特 */
    private val mFirstNellFetchFirstNellRepayFirstNellUrlFirstNellFCFAFirstNellLiveData =
        MutableLiveData<ReqBase>()

    /** 获取还款链接-越南 */
    private val mFirstNellFetchFirstNellRepayFirstNellUrlFirstNellVNDFirstNellLiveData =
        MutableLiveData<ReqBase>()

    /** 获取还款详情 */
    val onFirstNellFetchFirstNellRepayFirstNellDetailFirstNellLiveData =
        Transformations.switchMap(mFirstNellFetchFirstNellRepayFirstNellDetailFirstNellLiveData) { query ->
            ApiUserReposity.fetchFirstNellRepayFirstNellDetail(this, query)
        }

    /** 判断是否需要还款 */
    val onFirstNellFetchFirstNellIsFirstNellRepayFirstNellNowFirstNellLiveData =
        Transformations.switchMap(
            mFirstNellFetchFirstNellIsFirstNellRepayFirstNellNowFirstNellLiveData
        ) { query ->
            ApiUserReposity.fetchFirstNellIsFirstNellRepayFirstNellNow(this, query)
        }

    /** 获取还款链接-加纳 */
    val onFirstNellFetchFirstNellRepayFirstNellUrlFirstNellGHAFirstNellLiveData =
        Transformations.switchMap(
            mFirstNellFetchFirstNellRepayFirstNellUrlFirstNellGHAFirstNellLiveData
        ) { query ->
            ApiUserReposity.fetchFirstNellRepayFirstNellUrlFirstNellGHA(this, query)
        }

    /** 获取还款链接-乌干达 */
    val onFirstNellFetchFirstNellRepayFirstNellUrlFirstNellUGXFirstNellLiveData =
        Transformations.switchMap(
            mFirstNellFetchFirstNellRepayFirstNellUrlFirstNellUGXFirstNellLiveData
        ) { query ->
            ApiUserReposity.fetchFirstNellRepayFirstNellUrlFirstNellUGX(this, query)
        }

    /** 获取还款链接-肯尼亚 */
    val onFirstNellFetchFirstNellRepayFirstNellUrlFirstNellKSHFirstNellLiveData =
        Transformations.switchMap(
            mFirstNellFetchFirstNellRepayFirstNellUrlFirstNellKSHFirstNellLiveData
        ) { query ->
            ApiUserReposity.fetchFirstNellRepayFirstNellUrlFirstNellKSH(this, query)
        }

    /** 获取还款链接-科特 */
    val onFirstNellFetchFirstNellRepayFirstNellUrlFirstNellFCFAFirstNellLiveData =
        Transformations.switchMap(
            mFirstNellFetchFirstNellRepayFirstNellUrlFirstNellFCFAFirstNellLiveData
        ) { query ->
            ApiUserReposity.fetchFirstNellRepayFirstNellUrlFirstNellFCFA(this, query)
        }

    /** 获取还款链接-越南 */
    val onFirstNellFetchFirstNellRepayFirstNellUrlFirstNellVNDFirstNellLiveData =
        Transformations.switchMap(
            mFirstNellFetchFirstNellRepayFirstNellUrlFirstNellVNDFirstNellLiveData
        ) { query ->
            ApiUserReposity.fetchFirstNellRepayFirstNellUrlFirstNellVND(this, query)
        }

    /** 获取还款详情 */
    fun fetchFirstNellRepayFirstNellDetail(reqBase: ReqBase) {
        mFirstNellFetchFirstNellRepayFirstNellDetailFirstNellLiveData.value = reqBase
    }

    /** 获取还款链接-加纳 */
    fun fetchFirstNellRepayFirstNellUrlFirstNellGHA(reqBase: ReqBase) {
        mFirstNellFetchFirstNellRepayFirstNellUrlFirstNellGHAFirstNellLiveData.value = reqBase
    }

    /** 获取还款链接-乌干达 */
    fun fetchFirstNellRepayFirstNellUrlFirstNellUGX(reqBase: ReqBase) {
        mFirstNellFetchFirstNellRepayFirstNellUrlFirstNellUGXFirstNellLiveData.value = reqBase
    }

    /** 获取还款链接-肯尼亚 */
    fun fetchFirstNellRepayFirstNellUrlFirstNellKSH(reqBase: ReqBase) {
        mFirstNellFetchFirstNellRepayFirstNellUrlFirstNellKSHFirstNellLiveData.value = reqBase
    }

    /** 获取还款链接-科特 */
    fun fetchFirstNellRepayFirstNellUrlFirstNellFCFA(reqBase: ReqBase) {
        mFirstNellFetchFirstNellRepayFirstNellUrlFirstNellFCFAFirstNellLiveData.value = reqBase
    }

    /** 获取还款链接-越南 */
    fun fetchFirstNellRepayFirstNellUrlFirstNellVND(reqBase: ReqBase) {
        mFirstNellFetchFirstNellRepayFirstNellUrlFirstNellVNDFirstNellLiveData.value = reqBase
    }

    /** 判断是否需要还款 */
    fun fetchFirstNellIsFirstNellRepayFirstNellNow(reqBase: ReqBase) {
        mFirstNellFetchFirstNellIsFirstNellRepayFirstNellNowFirstNellLiveData.value = reqBase
    }
}